package com.feihao.zhou.exception;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@Controller
@ControllerAdvice   //功能增强
public class ExceptionAdvice {

    //业务类异常
    @ExceptionHandler(BusinessException.class)
    public String doBusinessException(Exception e, Model model){
        model.addAttribute("msg",e.getMessage());
        return "error.jsp";
    }


    //系统类异常
    @ExceptionHandler(SystemException.class)
    public String doSystemException(Exception e,Model model){
        model.addAttribute("msg",e.getMessage());
        //实际将问题显示收到redis服务器。运行查询检查
        return "error.jsp";
    }


    //其他异常
    @ExceptionHandler(Exception.class)
    public String Exception(Exception e,Model model){
        model.addAttribute("msg",e.getMessage());
        return "error.jsp";
    }
}
